/*
 * MIT License
 * 
 * Copyright (c) 2024 冰羽
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package cn.star.example.controller;

import cn.star.example.config.Config;
import cn.star.example.entity.Book;
import cn.star.example.service.BookService;
import cn.star.framework.monitor.annotation.MonitorMethod;
import cn.star.framework.monitor.MonitorType;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * BookController<br>
 * 
 * @author star
 *     <p style='color: red'>Created on 2024-09-23 11:06:00
 * @since  3.0.0
 */
@org.springframework.web.bind.annotation.RestController
@org.springframework.web.bind.annotation.RequestMapping(value = "/book")
public class BookController extends cn.star.framework.controller.AbstractController<Book, java.lang.String> {
  @org.springframework.beans.factory.annotation.Autowired @lombok.Getter private BookService service;

  @Autowired private Config config;

  @java.lang.Override
  @org.springframework.web.bind.annotation.PostMapping
  @MonitorMethod(types = MonitorType.WRITE_LOG, description = "新增数据")
  public cn.star.framework.core.api.AppResult save(@org.springframework.web.bind.annotation.RequestBody Book entity) {
    return super.save(entity);
  }

  @java.lang.Override
  @org.springframework.web.bind.annotation.PutMapping
  @MonitorMethod(types = MonitorType.DEMO_ENVIRONMENT_DISABLED)
  public cn.star.framework.core.api.AppResult update(@org.springframework.web.bind.annotation.RequestBody Book entity) {
    return super.update(entity);
  }

  @java.lang.Override
  @org.springframework.web.bind.annotation.DeleteMapping
  public cn.star.framework.core.api.AppResult deleteByIds(@org.springframework.web.bind.annotation.RequestBody java.lang.String... ids) {
    return super.deleteByIds(ids);
  }

  @org.springframework.web.bind.annotation.GetMapping
  public cn.star.framework.core.api.AppResult<java.util.List<Book>> list(javax.servlet.http.HttpServletRequest request) {
    return super.list(request, Book.class);
  }

  @java.lang.Override
  @org.springframework.web.bind.annotation.GetMapping("/{id}")
  public cn.star.framework.core.api.AppResult<Book> get(@org.springframework.web.bind.annotation.PathVariable(value = "id") java.lang.String id) {
    return super.get(id);
  }

  @org.springframework.web.bind.annotation.GetMapping("/page")
  public cn.star.framework.core.api.AppResult<cn.star.framework.core.api.Pageable<Book>> pageable(javax.servlet.http.HttpServletRequest request) {
    return super.pageable(request, Book.class);
  }

  @org.springframework.web.bind.annotation.PostMapping("/imp")
  @MonitorMethod(types = {MonitorType.WRITE_LOG, MonitorType.METHOD_EXECUTE_TIME}, description = "导入数据")
  public cn.star.framework.core.api.AppResult<java.lang.String> imp(javax.servlet.http.HttpServletRequest request, @org.springframework.web.bind.annotation.RequestParam("file") org.springframework.web.multipart.MultipartFile file) {
    return super.imp(config.getTmp(), request, file, Book.class);
  }

  @org.springframework.web.bind.annotation.GetMapping("/exp")
  public void exp(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
    super.exp(request, response, Book.class);
  }

}
